local BaseWnd = require(SCRIPTS_DIR .. ".wnds.BaseWnd");
local LoadingWnd = class("LoadingWnd",BaseWnd);
function LoadingWnd:ctor()
	LoadingWnd.super.ctor(self);
end

function LoadingWnd:setPrecent(pre)
    local curPencent = pre.data;
    self:widget("par.info"):setString(string.format("%0.0f",curPencent * 100) .. "%");
    self.process:setPercent(curPencent * 100);
    if curPencent >= 1.0 then
        mgrs.scheduler:performWithDelayGlobal(function()
            self:close();
        end,0.1);
    end
end

function LoadingWnd:onOpen()
    self.process = self:widget("par.load");
    self.label = self:widget("par.info");
    self.logo = self:widget("par.logo");
    self:addEventListener(enums.Event.LoadingAdd,handler(self,self.setPrecent));
    --mgrs.action:beginAction(self.logo):MoveBy(0.2,cc.p(0,10)):MoveBy(0.4,cc.p(0,-20)):MoveBy(0.2,cc.p(0,10)):Sequence(3):RepeatForever():endAction();
end



function LoadingWnd:onClose()
    
end

function LoadingWnd:getLayer()
	return enums.Layer.Loading;
end


mgrs.wnd:registerWnd(enums.Wnd.Loading,LoadingWnd);

